package com.demo.functionPackage;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.Function;

public class FunctionTest {
    public static <T, R> List<R> map(List<T> list, Function<T, R> function) {
        List<R> result = new ArrayList<>();
        for(T s: list) {
            result.add(function.apply(s));
        }
        return result;
    }

    public static void main(String[] args) {
        List<Integer> list = map(Arrays.asList("lambda", "in", "action"), String::length);
        System.out.println(list);
    }
}
